package com.springboot.service.mq.consumer;


import java.util.List;

import com.springboot.rmq.comm.ResultCode;
import com.springboot.rmq.consumer.MsgHandle;
import com.springboot.rmq.consumer.meta.MsgMeta;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.rocketmq.common.message.MessageExt;


@MsgMeta(
        topic = "userInfo",
        group = "RECHARGE_TAKE",
        tags = "user")
public class UserMsgHandler implements MsgHandle {

    /**
     * 日志
     */
    private static Log logger = LogFactory.getLog(UserMsgHandler.class);

    @Override
    public String dealMessage(List<MessageExt> msgs) {
        logger.info("会员开始消费");
        if (msgs != null && !msgs.isEmpty()) {
            MessageExt msg = msgs.iterator().next();
            if (msg == null) {
                // 消息不存在重新消费
                return ResultCode.CONCURRENT_RECONSUMER;
            }
            String body = new String(msg.getBody()); // 支付结果内容
            logger.info("mq积分增减操作接受到消息：：原消息-" + body);

        }
        return ResultCode.CONCURRENT_SUCCESS;
    }

}


